# coding=utf8
# 更新项目的关联产品

from app import create_app
from app.modules.common.utils import DbCommit
from app.modules.projectPlan.models import ProjectPlanInfo
from app.modules.zentao.resources import ZenTao

application = create_app(flask_config = 'local')


def main():
    with application.app_context():
        _list = ProjectPlanInfo.query.all()
        for _pro in _list:
            if _pro.zt_id is None:
                continue
            _product = ZenTao.ProjectProduct(_pro.zt_id)
            _pro.link_product = _product
        DbCommit()


if __name__ == '__main__':
    main()
    pass
